home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr01 / halcn305.zip / GSDMO_10.PAS < prev    next >
Pascal/Delphi Source File  |  1993-05-02  |  3KB  |  134 lines

  1. program GSDMO_10;
  2. {------------------------------------------------------------------------------
  3.                              DBase Multiple Indexes
  4.  
  5.        Copyright (c)  Richard F. Griffin
  6.  
  7.        20 January 1993
  8.  
  9.        102 Molded Stone Pl
  10.        Warner Robins, GA  31088
  11.  
  12.        -------------------------------------------------------------
  13.        Unit to demonstrate multiple index processing.  The indexes are
  14.        first created and then updated with more records to demonstrate
  15.        multiple indexes may be updated when a dBase record is added or
  16.        updated.
  17.  
  18.        The GSDMO_10.DBF file will be created by using the MakeTestData
  19.        procedure in GSOB_GEN.PAS.
  20.  
  21.        The IndexOn routine will be used to make index GSDMO10A.NDX on
  22.        LASTNAME+FIRSTNAME and index GSDMO10B.NDX on BIRTHDATE.
  23.  
  24.        The indexed file will be listed ascending using GSDM010A.
  25.  
  26.        Additional Records will be added to test multiple index update.
  27.  
  28.        Finally, the file will be listed again in LASTNAME+FIRSTNAME and
  29.        BIRTHDATE index sequence.  Note the use of SetOrderTo to switch
  30.        between which index is the master.
  31.  
  32.        New procedures/functions introduced are:
  33.  
  34.                  DBFActive
  35.                  SetOrderTo
  36.  
  37. -------------------------------------------------------------------------------}
  38.  
  39. uses
  40.    GSOB_Gen,
  41.    GSOBShel,
  42.    {$IFDEF WINDOWS}
  43.       WinCRT,
  44.       WinDOS;
  45.    {$ELSE}
  46.       CRT,
  47.       DOS;
  48.    {$ENDIF}
  49.  
  50. var
  51.    s       : string;
  52.    li      : boolean;
  53.    i       : integer;
  54.    c       : char;
  55.    jd      : longint;
  56.    ms      : string[30];
  57.    ix1     : integer;
  58.    ix2     : integer;
  59.  
  60. begin
  61.    ClrScr;
  62.  
  63.    writeln('Creating GSDMO_10.DBF');
  64.    MakeTestData(3,'GSDMO_10', 50, false);
  65.    writeln('GSDMO_10.DBF Created');
  66.  
  67.    SetCenturyOn;
  68.    Select(1);
  69.    Use('GSDMO_10');
  70.  
  71.    IndexOn('GSDMO10A','LASTNAME+FIRSTNAME');
  72.    IndexOn('GSDMO10B','BIRTHDATE');
  73.    Index('GSDMO10A, GSDMO10B');     {Assign both indexes to the database}
  74.    i := 0;
  75.    GoTop;
  76.    while (not dEOF) do
  77.    begin
  78.       inc(i);
  79.       if (i mod 23) = 0 then
  80.       begin
  81.          write('Press any key to continue.');
  82.          c := ReadKey;
  83.          writeln;
  84.       end;
  85.       writeln(RecNo:8,'   ',FieldGet('LASTNAME'),i:6);
  86.       Skip(1);
  87.    end;
  88.  
  89.    writeln('End of File, Now for More Records...');
  90.    writeln('Press any key to continue.');
  91.    c := ReadKey;
  92.  
  93.    writeln('Adding GSDMO_10.DBF Records');
  94.    AddTestData(DBFActive, 50);  {DBFActive is a pointer to current DBF object}
  95.    writeln('GSDMO_10.DBF Records Added');
  96.  
  97.    i := 0;
  98.    GoTop;
  99.    while (not dEOF) do
  100.    begin
  101.       inc(i);
  102.       if (i mod 23) = 0 then
  103.       begin
  104.          write('Press any key to continue.');
  105.          c := ReadKey;
  106.          writeln;
  107.       end;
  108.       writeln(RecNo:8,'   ',FieldGet('LASTNAME'),i:6);
  109.       Skip(1);
  110.    end;
  111.  
  112.    writeln('End of File, Now to check date sequence...');
  113.    writeln('Press any key to continue.');
  114.    c := ReadKey;
  115.  
  116.    SetOrderTo(2);                      {Now change to the GSDMO10B index}
  117.    i := 0;
  118.    GoTop;
  119.    while (not dEOF) do
  120.    begin
  121.       inc(i);
  122.       if (i mod 23) = 0 then
  123.       begin
  124.          write('Press any key to continue.');
  125.          c := ReadKey;
  126.          writeln;
  127.       end;
  128.       writeln(RecNo:8,'   ',
  129.               DTOC(DateGet('BIRTHDATE')),i:6);
  130.       Skip(1);
  131.    end;
  132.    CloseDataBases;
  133. end.
  134.